import { useSelector } from "react-redux";
import { StateType } from "../store";
import { ComponentStatetype } from "../store/componentReducer";

function useGetComponentInfo_redux() {
  const components = useSelector<StateType>((state) => {
    return state.componentReducer.present;
  }) as ComponentStatetype;
  //获取复制的组件
  const { componentList = [], selectedId = "", copyComponent = null } = components;

  //获取选择的组件信息
  const selectedComponent = componentList.find((c) => c.fe_id == selectedId);
  return { componentList, selectedId, selectedComponent, copyComponent };
}

export default useGetComponentInfo_redux;
